export const copyToClipboard = (text: string) => {
  const textarea = document.createElement('textarea');
  textarea.value = text;
  document.body.appendChild(textarea);
  textarea.select();
  document.execCommand('copy');
  document.body.removeChild(textarea);
};

export const generateShareLink = (inputText: string, translatedText: string) => {
  const encodedInput = encodeURIComponent(inputText);
  const encodedTranslation = encodeURIComponent(translatedText.split('潜台词是: ')[1]);
  return `${window.location.origin}?text=${encodedInput}&translation=${encodedTranslation}`;
};